/*
 * Copyright(c) 2023 NeatLogic Co., Ltd. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package neatlogic.framework.cmdb.enums.legalvalid;

import neatlogic.framework.common.constvalue.IEnum;
import neatlogic.framework.common.dto.ValueTextVo;
import neatlogic.framework.util.$;

import java.util.ArrayList;
import java.util.List;

public enum LegalValidType implements IEnum<ValueTextVo> {
    CI("ci", "模型规则"), CUSTOM("custom", "自定义规则");
    private final String type;
    private final String text;

    LegalValidType(String _type, String _text) {
        this.type = _type;
        this.text = _text;
    }

    public String getValue() {
        return type;
    }

    public String getText() {
        return $.t(text);
    }

    public static String getText(String name) {
        for (LegalValidType s : LegalValidType.values()) {
            if (s.getValue().equals(name)) {
                return s.getText();
            }
        }
        return null;
    }


    @Override
    public List<ValueTextVo> getValueTextList() {
        List<ValueTextVo> returnList = new ArrayList<>();
        for (LegalValidType s : LegalValidType.values()) {
            returnList.add(new ValueTextVo(s.getValue(), s.getText()));
        }
        return returnList;
    }
}
